package com.bachelor.community.mapper;

import com.bachelor.community.model.entity.Comment;
import com.bachelor.community.model.vo.CommentVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper extends BaseMapper<Comment> {
    @Select("select comment.id, comment.content, comment.create_time, comment.like_count, comment.reply_to, comment.answer_id, user.id as commentator_id, " +
            "user.username as commentator_name from comment left join user on comment.commentator=user.id where comment.answer_id=#{answerId} order by comment.create_time desc")
    List<CommentVO> selectCommentList(Integer answerId);
}
